package com.ydt.dockingclients.response;

import com.alibaba.fastjson2.JSON;
import com.ydt.dockingclients.request.SdkYdtOrderCreateNoticeRequest;
import com.ydt.dockingclients.request.SdkYdtOrderRefundNoticeRequest;
import com.ydt.dockingclients.utils.HttpServletRequestReader;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class YdtNoticeResponseHandel {

    /**
     * 油站变更推送（接收运达通通知接口）
     *
     * @param request
     * @return
     */
    public static YdtStationListDataResponse.DataDTO.RowsDTO changeNotice(HttpServletRequest request) {
        String body = HttpServletRequestReader.getBody(request);
        log.info("运达通油站变更接收：{}", body);
        YdtStationListDataResponse.DataDTO.RowsDTO ydtStationDataList = JSON.parseObject(body, YdtStationListDataResponse.DataDTO.RowsDTO.class);
        log.info("运达通油站变更接收：{}", ydtStationDataList);
        return ydtStationDataList;
    }

    /**
     * 订单创建回告（接收运达通通知接口）
     *
     * @param request
     * @return
     */
    public static SdkYdtOrderCreateNoticeRequest createNotice(HttpServletRequest request) {
        String body = HttpServletRequestReader.getBody(request);
        SdkYdtOrderCreateNoticeRequest noticeRequest = JSON.parseObject(body, SdkYdtOrderCreateNoticeRequest.class);
        log.info("运达通创建订单回告：{}", noticeRequest);
        return noticeRequest;
    }

    /**
     * 订单退款回告通知（接收运达通通知接口）
     *
     * @param request
     * @return
     */
    public static SdkYdtOrderRefundNoticeRequest refundNotice(HttpServletRequest request) {
        String body = HttpServletRequestReader.getBody(request);
        SdkYdtOrderRefundNoticeRequest noticeRequest = JSON.parseObject(body, SdkYdtOrderRefundNoticeRequest.class);
        log.info("运达通订退款单回告：{}", noticeRequest);
        return noticeRequest;
    }

}
